/*
  * @filename	:func.js
  * @author		:Pom
  * @email		:studicms@live.cn
  * @time		:2011-10-01
  * @explain	:调用插件和函数的文件
  * @version	:1.0
  */
 
$(function(){
	$("#addFavirute").click(function(){
        var currentUrl = window.location.href;
        var currentName = document.title;
		HomepageFavorite.Favorite(currentUrl,currentName);
		return false;
	})
});

//banner toggle
$(function(){
			// // Set starting slide to 1
			// var startSlide = 1;
			// // Get slide number if it exists
			// if (window.location.hash) {
				// startSlide = window.location.hash.replace('#','');
			// }
			// Initialize Slides
			// $('#slides-coupons').slides({
				// preload: true,
				// preloadImage: '../img/loading.gif',
				// generatePagination: false,
				// pagination: false,
				// //play: 4000,                    //去掉自动翻页
				// pause: 2500,
				// next: 's-icon2',
				// prev: 's-icon1',
				// hoverPause: true,
				// // Get the starting slide
				// start: startSlide,
				// animationComplete: function(current){
					// // Set the slide number as a hash
					// window.location.hash = '#' + current;
				// }
			// });
			$(function(){
			$('#slides-coupons').slides({
				preload: true,
				play: 4000, 
				generateNextPrev: false			//去掉next-prev翻页,隐藏翻页样式
			});
		});
});
$(function(){
	$(".pagination").wrap("<div class='wrap'></div>"); 
});
// //ie6 min-height and min-width
$(function(){
	$(".supply-img img").each(function(){
	$(this).height()>=90 ? $(this).height(90) : ""; 
	$(this).width()>=94 ? $(this).width(94) : "";	
	});
});
$(function(){
	$(".s-img img").each(function(){
	$(this).height()>=161 ? $(this).height(161) : ""; 													
	$(this).width()>=158 ? $(this).width(158) : "";	
	});
});
//去除最后ul中最后一个li 的边框的函数嗲用
$(function(){
	clearBorder("followTips");
	clearBorder("navTips");
	clearBorder("discount","add-one-px");
	clearBorder("tab-meun-id","add-one-px-tab");
	clearBorderBottom("col-list-id");
	clearBorderBottom("latest-business-id");
	clearBorderBottom("business-list-id");
	clearBorderBottom("desire-list-id");
	//clearBorderBottom("publish-list-id");
	clearBorderBottom("all-class-list-id");
	
});
//top 3 change red color
$(function(){
	topRedColor("lasted-activities");
	topRedColor("business-list-id");
	topRedColor("slides-coupons");
});
//tab 选项卡
$(function(){
	tabs("tab-meun-id","tab-box","md-tab-meun-selected","ul");
	tabs("tab-bus-id","tab-bus-box","md-tab-bus-selected","ul");
});
//mybaby level2 meun
$(function(){
	$("#mybabyClick").hover(function(){
		var that = $(this);
		that.addClass("none-border-right");
		that.find("ul").removeClass("hide");
	},function(){
		var that = $(this);
		that.removeClass("none-border-right");
		$(this).find("ul").addClass("hide");
	});
	$(".col-parts > a:even","#col-list-id").addClass("random-font-red");
	$(".mama-list-item-details","#discount").css({
		"opacity" : "0.7"
	});
	$(".mama-list-item ol").each(function(){
		$(this).find("li:even").addClass("even");
	});
});
$(function(){
	$(".hot-coupons-list").delegate("li","hover",function(){
		$(this).toggleClass("hover-coupons");
	});
	(function defaultState (){
		var liFirst = $("#business-list-id>li:first");
		liFirst.find(">dl").removeClass("hide");
		liFirst.find(">a").addClass("hide");
	})();
	$("#business-list-id>li").mouseover(function(){
		var that = $(this),
			thatSib = $(this).siblings(),
			sibDomA = thatSib.find(">a"),
			sibDomDl = thatSib.find(">dl"),
			domA = that.find(">a"),
			domDl = that.find(">dl")
		if(domA.hasClass("hide")){
			sibDomA.removeClass("hide");
			sibDomDl.addClass("hide");
			return;	
		}else{
			domA.addClass("hide");
			domDl.removeClass("hide");
			sibDomA.removeClass("hide");
			sibDomDl.addClass("hide");
		}
	});

});
//week-business level2 details
$(function(){
	$("#latest-business-id").delegate("li","hover",function(){
		$(this).toggleClass("ie-aside-relative");
		$(this).find("div.week-bus-wrap").toggleClass("hide");
	})
});


//backTop
$(function(){
        var evenTo = $('<a href="#" id="backTop" class="backTopClass">回到顶部</a>').appendTo('body').hide();
        evenTo.click(function(){
            $(document).scrollTop(0);            //将backTop插入body然后隐藏，当点击backTop时候返回顶部并且隐藏。
            $(this).hide();
            return false;
        });
        var backTop = $('#backTop');
        function elePosition(){
            var positionLeft = $(window).width() / 2 + 480;
           	//alert(positionLeft);
            if(positionLeft <= 960){
                backTop.css('left',960);        //小于等于980 也就是1024的分辨率 17的显示器
            }else{
                backTop.css('left',positionLeft);
            }
        }
        elePosition();
        $(window).resize(elePosition);
        $(window).scroll(function(){
            if($(document).scrollTop() === 0){
                backTop.hide();
            }else{
                backTop.show();
            }
            if ($.browser.msie && $.browser.version == 6.0 && $(document).scrollTop() !== 0) {
                 backTop.css({
                    'opacity': 1,
                    'right': 960,
					'position' : 'absolute'
                })
             }
        });
});

//单行文字和多行文字函数调用
$(function(){
	autoScroll("#refresh-single","li");
	$("#publish-list-id").Scroll({
		line : 6,
		speed : 500,
		timer : 5000,
		up : "",
		down : ""
	});
});
